home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 July / Disc 1 / PCU0703CD1.iso / software / online / files / imacros.exe / FORM1.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2002-11-29  |  6.2 KB  |  195 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Internet Macros"
  4.    ClientHeight    =   1965
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   5895
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   1965
  10.    ScaleWidth      =   5895
  11.    StartUpPosition =   3  'Windows-Standard
  12.    Begin VB.CommandButton bt_exchange_rate 
  13.       Caption         =   "Get US$ exchange rate"
  14.       Height          =   525
  15.       Left            =   330
  16.       TabIndex        =   5
  17.       Top             =   570
  18.       Width           =   1245
  19.    End
  20.    Begin VB.CommandButton Command3 
  21.       Caption         =   "Close"
  22.       Height          =   285
  23.       Left            =   4710
  24.       TabIndex        =   4
  25.       Top             =   1500
  26.       Width           =   765
  27.    End
  28.    Begin VB.CheckBox chkTray 
  29.       Caption         =   "Run macros in system tray"
  30.       Height          =   285
  31.       Left            =   330
  32.       TabIndex        =   2
  33.       Top             =   1500
  34.       Width           =   3405
  35.    End
  36.    Begin VB.CommandButton Command2 
  37.       Caption         =   "Order Dinner"
  38.       Height          =   525
  39.       Left            =   4020
  40.       TabIndex        =   1
  41.       Top             =   570
  42.       Width           =   1245
  43.    End
  44.    Begin VB.CommandButton Command1 
  45.       Caption         =   "Order Lunch"
  46.       Height          =   525
  47.       Left            =   2175
  48.       TabIndex        =   0
  49.       Top             =   570
  50.       Width           =   1245
  51.    End
  52.    Begin VB.Label lbl_message 
  53.       BackColor       =   &H00C0FFFF&
  54.       BorderStyle     =   1  'Fest Einfach
  55.       Caption         =   "IIM Messages"
  56.       Height          =   405
  57.       Left            =   3510
  58.       TabIndex        =   7
  59.       Top             =   30
  60.       Width           =   2265
  61.    End
  62.    Begin VB.Label Label2 
  63.       Caption         =   "Status:"
  64.       Height          =   225
  65.       Left            =   2850
  66.       TabIndex        =   6
  67.       Top             =   120
  68.       Width           =   585
  69.    End
  70.    Begin VB.Label Label1 
  71.       Caption         =   "Visual Basic Example Program"
  72.       Height          =   225
  73.       Left            =   90
  74.       TabIndex        =   3
  75.       Top             =   90
  76.       Width           =   2205
  77.    End
  78. Attribute VB_Name = "Form1"
  79. Attribute VB_GlobalNameSpace = False
  80. Attribute VB_Creatable = False
  81. Attribute VB_PredeclaredId = True
  82. Attribute VB_Exposed = False
  83. 'iOpus Internet Macros
  84. 'http://www.iopus.com/iim.htm
  85. '(c) iOpus Software GmbH
  86. Dim iim1 As Object
  87. Dim bUseOpenIIM As Boolean
  88. Private Sub Form_Load()
  89. 'Create an object based on the Scripting Interface
  90. 'This way we can copy & paste all the VBS (Windows Scripting) example code
  91. 'directly into a VB project
  92. Set iim1 = CreateObject("iimwsh.iim")
  93. 'Alternative: You can also add "iimwsh.ocx" to your list of VB compoments
  94. 'and then drag and drop it on your form (just like, for example, a timer object)
  95. End Sub
  96. Private Sub bt_exchange_rate_Click()
  97. Dim sSplit() As String
  98. Dim data As String
  99. Dim d0 As String
  100. Dim d1 As String
  101. Dim sCmdLine As String
  102. lbl_message = "Running..."
  103. 'Initialize and start IIM browser
  104. If chkTray.Value = 1 Then sCmdLine = "-tray"
  105. iret = iim1.iimInit(sCmdLine, True)
  106. 'Tip: With iret = iim1.iimInit(sCmdLine, FALSE) you can ask the Scripting Interface to
  107. 'connect to an already open IIM browser. If there is no IIM browser open, the return value
  108. 'will be negative.
  109. iret = iim1.iimDisplay("Extract Example")
  110. 'Set a new command line for the next PLAY command
  111. If chkTray.Value = 1 Then iret = iim1.iimSet("-tray", "")
  112. 'Normally the Scripting Interface waits about 10 seconds before a Scripting Interface
  113. 'timeout error occurs (for example, if a user closed the IIM browser while it was running,
  114. 'please do not confuse this with the BROWSER timeout errors if a web page loads too slow.)
  115. 'iret = iim1.iimSetInternal("INTERFACETIMEOUT", 1)  'reduce the interface timeout to 1s
  116. iplay = iim1.iimPlay("wsh-extract")
  117. data = iim1.iimGetLastMessage()
  118. iret = iim1.iimExit
  119. If iplay = 2 Then
  120.     lbl_message = "Done!"
  121.     sSplit = Split(data, "[EXTRACT]")
  122.     d0 = sSplit(0)
  123.     If UBound(sSplit) > 0 Then d1 = sSplit(1)
  124.     S = "One US$ costs " + d0 + " EURO or " + d1 + " British Pounds (GBP)"
  125.     MsgBox S
  126.     lbl_message = "Done!"
  127. End If
  128. If iplay = 1 Then
  129.     lbl_message = "Done, but no data extracted"
  130. End If
  131. If iplay < 0 Then
  132.     lbl_message = data
  133. End If
  134. End Sub
  135. Private Sub Command1_Click()
  136. 'Order Lunch
  137. lbl_message = "Running..."
  138. If chkTray.Value = 1 Then
  139. iret = iim1.iimInit("-tray")
  140. iret = iim1.iimInit
  141. End If
  142. iret = iim1.iimDisplay("Start First Part")
  143. If chkTray.Value = 1 Then iret = iim1.iimSet("-tray", "")
  144. iret = iim1.iimPlay("wsh-start")
  145. If iret < 0 Then
  146. 'MsgBox iim1.iimGetLastMessage()
  147. lbl_message = iim1.iimGetLastMessage()
  148. End If
  149. iret = iim1.iimPlay("wsh-lunch")
  150. If iret < 0 Then
  151. 'MsgBox iim1.iimGetLastMessage()
  152. lbl_message = iim1.iimGetLastMessage()
  153. End If
  154. iret = iim1.iimDisplay("Almost done!")
  155. iret = iim1.iimPlay("wsh-submit")
  156. 'Typically "iimPlay" is the only command where errors can occur
  157. If iret < 0 Then
  158. 'MsgBox iim1.iimGetLastMessage()
  159. lbl_message = iim1.iimGetLastMessage()
  160. lbl_message = "Done!"
  161. End If
  162. iret = iim1.iimExit
  163. End Sub
  164. Private Sub Command2_Click()
  165. 'Order Dinner
  166. lbl_message = "Running..."
  167. If chkTray.Value = 1 Then
  168. iret = iim1.iimInit("-tray")
  169. iret = iim1.iimInit
  170. End If
  171. iret = iim1.iimDisplay("Start First Part")
  172. If chkTray.Value = 1 Then iret = iim1.iimSet("-tray", "")
  173. 'Navigate to the order page
  174. iret = iim1.iimPlay("wsh-start")
  175. If iret < 0 Then
  176. lbl_message = iim1.iimGetLastMessage()
  177. End If
  178. iret = iim1.iimPlay("wsh-dinner")
  179. If iret < 0 Then
  180. 'MsgBox iim1.iimGetLastMessage()
  181. lbl_message = iim1.iimGetLastMessage()
  182. End If
  183. iret = iim1.iimDisplay("Almost done!")
  184. 'Submits the order
  185. iret = iim1.iimPlay("wsh-submit")
  186. If iret < 0 Then 'Typically "iimPlay" is the only command where errors can occur (for example, a timeout error)
  187. lbl_message = iim1.iimGetLastMessage()
  188. lbl_message = "Done!"
  189. End If
  190. 'Close IIM
  191. iret = iim1.iimExit
  192. End Sub
  193. Private Sub Command3_Click()
  194. End Sub
  195.